package com.ht.module.bus.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.util.StringUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.util.CollectionUtils;
import com.ht.module.bus.service.IBusDictService;
import com.ht.util.*;
import com.ht.module.bus.entity.BusDict;

import javax.validation.Valid;
import java.util.*;


/**
 * <p>
 * 业务字典关联表 前端控制器
 * </p>
 *
 * @author Auto-generator
 * @since 2021-12-03
 */
@Api(tags = "业务字典关联表 ")
@RestController
@RequestMapping("/bus-dict")
public class BusDictController {

    
    @Autowired
    private IBusDictService iBusDictService;

    


    /**
    * 分页查询
    */
    @ApiOperation(value = "分页查询")
    @GetMapping("/findPage")
    public JsonResult findPage(Pager<BusDict> pager, BusDict busDict){
        return JsonResult.success(iBusDictService.page(pager));
    }


    /**
    * 通过id查询
    */
    @GetMapping("/get-by-id/{id}")
    @ApiOperation(value = "通过id查询")
    public JsonResult getById(@PathVariable(value = "id") String id){
        return JsonResult.success(iBusDictService.getById(id));
    }

    /**
    * 新增
    */
    @PostMapping("/add")
    @ApiOperation(value = "新增")
    public JsonResult add(@RequestBody @Valid BusDict busDict){
        iBusDictService.save(busDict);
        return JsonResult.success();
    }

    /**
    * 通过id删除
    */
    @DeleteMapping("/delete-by-id/{id}")
    @ApiOperation(value = "删除")
    public JsonResult delete(@PathVariable(value = "id") String id){
        iBusDictService.removeById(id);
        return JsonResult.success();
    }

    /**
    * 修改
    */
    @PutMapping("/update")
    @ApiOperation(value = "修改")
    public JsonResult updateById(@RequestBody @Valid BusDict busDict){
        iBusDictService.updateById(busDict);
        return JsonResult.success();
    }

}
